<?php

namespace C\S\Housing;

use C\L\Service;

class SigninUserReward extends Service
{

    protected function setModel()
    {
        $this->model = new \C\M\SigninUserReward();
    }

    public function getDetail($data)
    {
        foreach ($data as $k => $v) {
            $where[] = $k.'='.$v;
        }
        $info = $this->model->get($data);

        if (!$info) {
            return [];
        }
        $info['reward'] = json_decode($info['reward'], true);

        return $info;
    }

    public function thisMonthSigninReward($conditions)
    {
        $list = $this->model->find(
            [
                        'conditions' => 'is_delete=0 AND '.$conditions,
                    ]
        )->toArray();
        
        $res = [];
        foreach ($list as &$v) {
            $v['reward'] = json_decode($v['reward'], true);
            $res[$v['sys_signin_id']] = $v;
        }
        return $res;
    }
}
